Memory buffers are typically used to temporarily store related data (e.g., a plurality of social security numbers) in a contiguous address space or collection of contiguous memory regions to facilitate efficient access of the related data during execution of a program. The buffers are implemented in portions of physical memory as well as virtual memory (i.e., in software) which include memory regions having virtual addresses mapped to physical addresses of the physical memory.
Typically, the size of a memory buffer is not checked when the buffer is accessed (i.e., the related data is written to the buffer), allowing accesses to memory regions outside (e.g., adjacent to) the buffer. As a result of an address calculation exceeding the bounds of a buffer, data is written to the memory regions outside the buffer resulting in a buffer overflow. Buffer overflows contribute to a variety of undesirable events, such as program crashes, data corruption, and security issues.